<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link href="../plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
		<!--<link href="../plugins/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css" />-->
		<link rel="stylesheet" href="../plugins/bootstrap-table/bootstrap-table.css" />
		<!--<link rel="stylesheet" href="../../plugins/layui/css/layui.css" media="all" />-->

		<style type="text/css">
			.container {
				padding-left: 3px;
				padding-right: 3px;
				padding-top: 15px;
			}
		</style>
	</head>

	<body>
		<div class="layui-container container">
			<table id="table"></table>
		</div>

		<script src="../common/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
		<script src="../plugins/bootstrap-table/bootstrap-table.js" type="text/javascript"></script>
		<script src="../plugins/bootstrap-table/locale/bootstrap-table-zh-CN.js" type="text/javascript" charset="utf-8"></script>
		<!--<script src="../../js/plan/expendtureYearSumByDept.js" type="text/javascript"></script>-->

		<script type="text/javascript">
			var col = [{
					checkbox: true
				},
				{
					title: '流程定义名称',
					field: 'name',
					align: 'center',
					valign: 'middle'
				},
				{
					title: '流程定义key',
					field: 'key',
					align: 'center',
					valign: 'middle'
				},
				{
					title: '版本',
					field: 'version',
					align: 'center',
					valign: 'middle'
				},
				{
					title: '部署ID',
					field: 'deploymentId',
					align: 'center',
					valign: 'middle'
				},
				{
					title: '操作',
					formatter: function(value, row, index) {
						return '<button class="layui-btn layui-btn-primary layui-btn-mini" onclick=\'start("/actres/start"'+row.key+'")\'>启动流程</button>&nbsp;&nbsp;&nbsp;'+
						'<button class="layui-btn layui-btn-mini" onclick="del(\''+row.deploymentId+'\')">删除</button>';
					},
					align: 'center',
					valign: 'middle',
					visible: true
				}
			];
			$('#table').bootstrapTable({
				url: baseUrl+'/actres',
				queryParams: function(params) {
					return {}
				},
				type: "get",
				toolbar: "#toolbar",
				detailView: false,
				locale: 'zh-CN',
				dataType: "json",
				sidePagination: "client",
				striped: true,
				pagination: true,
				queryParamsType: '', //默认值为 'limit' ,在默认情况下 传给服务端的参数为：offset,limit,sort
				// 设置为 ''  在这种情况下传给服务器的参数为：pageSize,pageNumber
				singleSelect: false,
				pageSize: 2,
				cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
				pageNumber: 1,
				pageList: 30,
				search: false, //不显示 搜索框
				uniqueId: "id", //每一行的唯一标识，一般为主键列
				undefinedText: '',
				columns: col,
				onLoadError: function(data) { //加载失败时执行  

				}
				//				onExpandRow: function(index, row, $detail) {
				//					InitSubTable(index, row, $detail);
				//				},
			});
			var start=function (key){
				$.get("/actres/start?processDefinitionKey="+key,function(data){
					alert(data);
				});
			}
			function del(id){
				console.log(id);
				$.ajax({
					type:"delete",
					url:baseUrl+"/actres?processDefinitionId="+id,
					async:true,
					data:{
						'processDefinitionId':id
					},
					success:function(data){
						window.location.reload();
					}
				});
			}
		</script>
	</body>

</html>